package com.lvy.hczn.transmit.controller;

import com.lvy.hczn.front.common.core.domain.AjaxResult;
import com.lvy.hczn.front.common.exception.UtilException;
import com.lvy.hczn.front.system.domain.business.dto.ParcelDto;
import com.lvy.hczn.mq.rocket.ParamInfo;
import com.lvy.hczn.transmit.service.TParcelService;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.lvy.hczn.front.common.core.controller.BaseController;

import javax.servlet.http.HttpServletRequest;

/**
 * 包裹信息Controller
 *
 * @date 2025-04-17
 */
@RequestMapping("/api/dt/parcel/")
@RestController
@Slf4j
public class TParcelController extends BaseController
{
    @Autowired
    private TParcelService parcelService;

    @ApiOperation(value = "包裹信息同步", notes = "包裹信息同步")
    @PostMapping("data")
    public AjaxResult syncParcelPlatform(HttpServletRequest request, @RequestBody ParcelDto parcelDto){
        try {
            parcelService.syncParcelPlatform(request, parcelDto);
            return AjaxResult.success();
        } catch (Exception e) {
            if (e instanceof UtilException) {
                return AjaxResult.error(e.getMessage());
            } else {
                log.error("syncParcelPlatform同步异常：", e);
                return AjaxResult.error("系统异常");
            }
        }
    }

}
